package com.suixun.entity.ext.credits.company;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.suixun.entity.ext.credits.BaseEntity;

/**
 * 商品列表
 * 
 * @author yh
 * @date 2017年12月15日
 */
public class GoodsArchivesPage extends BaseEntity {

    /**
     * 商品档案序列号
     */
    private String uuid;

    /**
     * 是否展示
     */
    private String isShow;

    /**
     * 商品所有投放区域的投放对象 多个用','分割
     */
    private String putRanges;

    /**
     * 商品所有投放区域的投放对象显示值
     */
    private String putRangesShow;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    /**
     * 商户名称
     */
    @JsonIgnore
    private String companyName;

    /**
     * 需要消耗的积分数
     */
    @JsonIgnore
    private Integer consumeCredit;

    /**
     * 总库存
     */
    @JsonIgnore
    private Integer totalNum;

    /**
     * 有效期开始时间
     */
    @JsonIgnore
    private Date beginTime;

    /**
     * 有效期到期时间
     */
    @JsonIgnore
    private Date endTime;

    /**
     * 商品类型:1免费券2特价券3抵用券4折扣券
     */
    @JsonIgnore
    private Short goodsType;

    /**
     * 商品市场价
     */
    @JsonIgnore
    private BigDecimal price;
    /**
     * 是否置顶
     */
    private Boolean isTop;

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public Integer getConsumeCredit() {
        return consumeCredit;
    }

    public void setConsumeCredit(Integer consumeCredit) {
        this.consumeCredit = consumeCredit;
    }

    public Integer getTotalNum() {
        return totalNum;
    }

    public void setTotalNum(Integer totalNum) {
        this.totalNum = totalNum;
    }

    public Date getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(Date beginTime) {
        this.beginTime = beginTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public Short getGoodsType() {
        return goodsType;
    }

    public void setGoodsType(Short goodsType) {
        this.goodsType = goodsType;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public String getIsShow() {
        if (isShow != null) {
            this.isShow = "是";
        } else {
            this.isShow = "否";
        }
        return isShow;
    }

    public void setIsShow(String isShow) {
        this.isShow = isShow;
    }

    public String getPutRanges() {
        return putRanges;
    }

    public void setPutRanges(String putRanges) {
        this.putRanges = putRanges;
    }

    public Boolean getIsTop() {
		return isTop;
	}

	public void setIsTop(Boolean isTop) {
		this.isTop = isTop;
	}

	public String getPutRangesShow() {
        if (StringUtils.isEmpty(putRanges)) {
            putRangesShow = "未投放";
        } else {
            String[] ranges = putRanges.split(",");
            List<String> list = new ArrayList<>();
            for (String s : ranges) {
                switch (Integer.parseInt(s)) {
                case 0:
                    list.add("所有");
                    break;
                case 1:
                    list.add("教师");
                    break;
                case 2:
                    list.add("家长");
                    break;
                }
            }
            putRangesShow = StringUtils.join(list, ",");
        }
        return putRangesShow;
    }

    public void setPutRangesShow(String putRangesShow) {
        this.putRangesShow = putRangesShow;
    }

}
